package net.UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

public class Clent {
    public static void main(String[] args) throws Exception {
        DatagramSocket datagramSocket = new DatagramSocket();
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("请输入消息:");
            String next = scanner.next();
            byte[] bytes = next.getBytes();
            if ("exit".equals(next)){
                break;
            }
            InetAddress localHost = InetAddress.getLocalHost();
            DatagramPacket packet = new DatagramPacket(bytes, bytes.length, localHost, 6666);
            datagramSocket.send(packet);
        }
        datagramSocket.close();
    }
}
